<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学习资料标签')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tag-edit" th:object="${materialTag}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">标签名：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">热门标签显示：</label>
                <div class="col-sm-8">
                    <label class="toggle-switch switch-solid"/>
                        <input type="checkbox" id="showHot" th:checked="${materialTag.showHot == 0 ? false : true}">
                        <span></span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "dict/tag";
        $("#form-tag-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-tag-edit').serializeArray()
                var showHot = $("input[id='showHot']").is(':checked') == true ? 1 : 0;
            	data.push({"name": "showHot", "value": showHot});
                $.operate.save(prefix + "/edit", data);
            }
        }
    </script>
</body>
</html>